import * as THREE from "three";
// import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { SVGLoader } from "three/examples/jsm/loaders/SVGLoader.js";
// const loader = new GLTFLoader();
const loaderSVG = new SVGLoader();
const model = new THREE.Group();
model.position.set(-(944 / 2), -(265 / 2), 0); // 改变组对象顶点坐标
const geometry = new THREE.PlaneGeometry(944, 265);
geometry.translate(944 / 2, 265 / 2, 0);
const texLoader = new THREE.TextureLoader();
export const texture10 = texLoader.load(require("@/views/witness/components/Object3D/canvas/10f@2x.png"));
export const texture12 = texLoader.load(require("@/views/witness/components/Object3D/canvas/12f备份@2x.png"));
const material = new THREE.MeshLambertMaterial({
  map: texture10, // map表示材质的颜色贴图属性
  transparent: true, // 开启透明，这样png贴图的透明部分不显示
  // side:THREE.DoubleSide,
  // color:0x0A1C45
  emissive: 0xffffff,// 自发光颜色
  emissiveIntensity: -0.1,   // 设置自发光的强度（默认值为 1）

});
material.map.encoding = THREE.sRGBEncoding;
// wanger 警告标识
const texWangerLoader = texLoader.load(require("@/views/witness/components/Object3D/canvas/告警.png"));
const texWangerLoaderBG  =  texLoader.load(require("@/views/witness/components/Object3D/canvas/形状结合@2x.png"));
// const num = 2;
// texWangerLoader.repeat.set(1 / num, 1);
const GeoWanger = new THREE.PlaneGeometry(14, 14);
const GeoWangerBG = new THREE.PlaneGeometry(60, 20);
const matWanger = new THREE.MeshBasicMaterial({
  map: texWangerLoader,
  transparent: true,
  // color: 0xff0000,
  side: THREE.DoubleSide
  // alphaMap:new THREE.Color('#fff')
});
const matWangerBG = new THREE.MeshBasicMaterial({
  map: texWangerLoaderBG,
  transparent: true,
  // color: 0xff0000,
  side: THREE.DoubleSide
  // alphaMap:new THREE.Color('#fff')
});

export const meshWanger = new THREE.Mesh(GeoWanger, matWanger);
export const meshWangerBG = new THREE.Mesh(GeoWangerBG, matWangerBG);
// let t = 0;
// const  UpdateWanger= (mesh, data) => {
//   t += 24;
//   if (t > 48) {
//     t = 0;
//   }
//   texWangerLoader.offset.x = t;
//   window.requestAnimationFrame(UpdateWanger);
// }
// UpdateWanger()
// 楼层
export const mesh = new THREE.Mesh(geometry, material);
mesh.name = "场地";
model.add(mesh);
export default model;
